home *** CD-ROM | disk | FTP | other *** search
- Path: munta.cs.mu.OZ.AU!fjh
- From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
- Newsgroups: comp.lang.misc,comp.lang.perl.misc,comp.lang.tcl,comp.lang.c,comp.lang.java
- Subject: Re: Relative Speed of Perl vs. Tcl vs. C [indentation]
- Date: 19 Feb 1996 04:02:31 GMT
- Organization: Comp Sci, University of Melbourne
- Message-ID: <4g8son$gmd@mulga.cs.mu.OZ.AU>
- References: <4g0bd6INNn9j@keats.ugrad.cs.ubc.ca> <4g1h0a$l72@orac.mon.rnb.com> <MARKT.96Feb16162033@atlas.harlqn.co.uk>
- NNTP-Posting-Host: munta.cs.mu.oz.au
-
- markt@harlqn.co.uk (Mark Tillotson) writes:
-
- >hdavies@kzin.mon.rnb.com (Hugh J.E. Davies) wrote:
- >
- > > I actually like code that structures blocks by indentation, since it
- > > makes writing folding editors simple and it lays to rest once and for
- > > all the religious wars over brace placement. OTOH, I've never even
- > > *seen* any Python. (Other than Monty.)
-
- >No no no no no. The reasons why this is a fundamentally flawed idea
- >are endless:
-
- I'm not familiar with Python, but I'm familiar with Haskell, which also
- uses whitespace to structure code.
-
- >linewrap,
-
- This is not a problem in Haskell; you just need to make sure that
- you indent the wrapped part of the line, e.g.
-
- this is a very long statement of pseudo-haskell that doesn't quite
- fit on one line
-
- >tabs,
-
- So disallow them!
-
- >painful to automatically generate code,
-
- In Haskell it is not painful to automatically generate code, because
- Haskell does not *require* the use of layout to indicate nesting;
- curly braces and semicolons can be used instead. You can also
- mix the use of implicit nesting (via layout) and explicit nesting
- (via curly braces and semicolons).
-
- >virtually impossible to stream-edit code,
-
- Huh? Why?
-
- >proportional fonts,
-
- Even proportional fonts don't have proportional whitespace!
-
- >breakable v. non-breakable spaces of differing widths,
-
- So just make sure the language only allows one type of space.
-
- >difficulty of cut-and-paste,
-
- Good! Cut-and-paste reuse is the worst kind. Programmers that would
- cut-and-paste without fixing the indentation should be taken out and
- shot.
-
- Anyway, how difficult is it to learn the `block indent' command in your
- editor?
-
- >impossible to use yacc-style tools,
-
- This is not true; it's really quite easy to write a yacc parser for Haskell.
- You just need a tiny bit of cleverness in the lexer. (Nothing as tricky
- as the feedback from parser to lexer required to parse C, for example.)
-
- >difficult to read out over the phone,
-
- You really want to read complicated code fragments over the phone? Ugh!
- Use the fax! Or email. If you really must read things over the phone,
- then you can use the curly braces and semicolons format for that
- purpose. (It's trivial for your compiler vendor to provide a tool to
- automatically convert code to that format.) But anyway, I think this
- is such a rare activity that it is not the important thing to optimize;
- optimizing readability is much more important.
-
- >hard to internationalize,
-
- Why on earth is it hard to internationalize?
- I guess the ancient Egyption hieroglyph scribes didn't use spaces,
- but how many modern character sets don't include a space character?!?!
-
- The notion of indentation still works fine even if you write your text
- right-to-left and bottom-to-top.
-
- >sensitive to identity of newline character,
-
- So? Many, if not most, languages already have syntax that is sensitive
- to the identity of the newline character. Examples include C, C++, Perl,
- Basic, Fortan, sh, etc., etc.
-
- Try
-
- #include <stdio.h> main() { printf("hello world\n"); }
-
- with your favourite C compiler!
-
- >macros,
-
- If you really must use syntax macros, then you can use the curly braces
- and semicolons method of specifying nesting within them.
-
- But a much better solution is to not use syntax macros at all -- they
- cause a huge number of problems in practice. If you do want macros,
- use something which works at a higher semantic level, such as lisp
- macros, C++ templates, or higher-order functions in Haskell.
-
- >statements inside expressions, ...
-
- What does that have to do with anything? Sounds just like another
- nesting construct to me. I don't see why it would pose any problems.
-
- >It is simply not a good idea, whitespace is too volatile to be a
- >syntactic marker, and counting spaces is too far removed from language
- >theory.
-
- I respectfully disagree. The idea is not fundamentally flawed.
- It works just fine in practice.
-
- The only question is whether the resulting code is really more readable ;-)
-
- --
- Fergus Henderson WWW: http://www.cs.mu.oz.au/~fjh
- fjh@cs.mu.oz.au PGP: finger fjh@128.250.37.3
-